package cn.com.dcsgo.library.admin.service.impl;

import cn.com.dcsgo.library.admin.domain.po.User;
import cn.com.dcsgo.library.admin.mapper.UsersMapper;
import cn.com.dcsgo.library.admin.service.IUsersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * @author Dcsgo
 * @since 2024-09-02
 */
@Service
public class UsersServiceImpl extends ServiceImpl<UsersMapper, User> implements IUsersService {

    @Override
    public User getByUsername(String username) {
        User users = lambdaQuery().eq(User::getUsername, username).one();
        if (users == null) {
            throw new IllegalArgumentException(username + " 用户不存在");
        }
        return users;
    }

    @Override
    public void login(String username, String password) {
        User users = getByUsername(username);
        if (!users.getPassword().equals(password)) {
            throw new IllegalArgumentException("密码错误");
        }
    }
}
